home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9103 / cea2.mar < prev    next >
Text File  |  1991-01-28  |  2KB  |  57 lines

  1. /*****************************************************************
  2. *  InGroup.C
  3. *  written by Kathy Cea, Platinum Software Int'l
  4. *
  5. *  InGroup is a utility to check whether the user is a member of
  6. *  a specified group. Designed to be used from a DOS batch file.
  7. *
  8. *  Calling Syntax:
  9. *     InGroup <group-name>
  10. *        <group-name> - The name of the group to be checked
  11. *
  12. *   Returns the following:
  13. *       0 - User is member of group
  14. *       1 - No group name was supplied on the command line
  15. *       2 - User is not a member of group
  16. *       3 - Group does not exist
  17. *       4 - Other error
  18. *
  19. *   Compiled in Turbo C 2.0 with NetWare C function calls
  20. *****************************************************************/
  21.  
  22. #include <stdio.h>
  23. #include <nit.h>
  24. #include <niterror.h>
  25.  
  26. WORD ConnectNumber;
  27. char objectName[48],groupname[48];
  28. WORD objectType;
  29. long objectID;
  30. BYTE loginTime[7];
  31.  
  32. main(int argc, char *argv[])
  33. {
  34.        if(argc < 2) {
  35.             printf("No group name supplied\n");
  36.             exit(1);
  37.     }
  38.     strcpy(groupname, argv[1]);
  39.  
  40. /* Get user's object name */
  41.     ConnectNumber =  GetConnectionNumber();
  42.     GetConnectionInformation(ConnectNumber, objectName,
  43.             &objectType, &objectID,loginTime);
  44.  
  45.     switch(IsBinderyObjectInSet(groupname, OT_USER_GROUP,"GROUP_MEMBERS",
  46.             objectName, OT_USER)){
  47.         case SUCCESSFUL:
  48.             exit(0);
  49.         case NO_SUCH_MEMBER:
  50.             exit(2);
  51.         case NO_SUCH_OBJECT:
  52.             exit(3);
  53.         default:
  54.             exit(4);
  55.         }
  56. }
  57.